Ext.namespace('changPwd');
/**
 * 用户名
 */
changPwd.user_name;
/**
 * 密码
 */
changPwd.pwd;
/**
 * 新密码
 */
changPwd.new_pwd;
/**
 * 确认新密码
 */
changPwd.new_pwd_agin;
/**
 * 修改密码面板
 */
changPwd.changPanel = new Ext.FormPanel({
			labelWidth : '50%',
			frame : true,
			bodyStyle : 'padding:5px 5px 0',
			layout : 'column',
			columnWidth : 1,
			items : [{
						layout : 'form',
						columnWidth : 1,
						items : [{
									xtype : 'textfield',
									anchor : '90%',
									fieldLabel : '用户名',
									name : 'user_name',
									id : 'user_name',
									allowBlank : false,
									blankText : '用户名必填',
									emptyText : '请输入用户名'
								}, {
									xtype : 'textfield',
									anchor : '90%',
									inputType : "password",
									fieldLabel : '密码',
									name : 'pwd',
									id : 'pwd',
									allowBlank : false

								}, {
									xtype : 'textfield',
									anchor : '90%',
									fieldLabel : '新密码',
									inputType : "password",
									name : 'new_pwd',
									id : 'new_pwd',
									allowBlank : false
								}, {
									xtype : 'textfield',
									anchor : '90%',
									fieldLabel : '确认新密码',
									inputType : "password",
									name : 'new_pwd_agin',
									id : 'new_pwd_agin',
									allowBlank : false
								}]
					}]
		});
// 调用changPwdOpeartion()返回密码修改的Panel
function changPwdOpeartion() {
	return changPwd.changPanel;
};
// 调用doupdateChangePwd() 函数执行修改操作
function doupdateChangePwd() {
	changPwd.user_name = changPwd.changPanel.findById("user_name").getValue();
	changPwd.pwd = changPwd.changPanel.findById("pwd").getValue();
	changPwd.new_pwd = changPwd.changPanel.findById("new_pwd").getValue();
	changPwd.new_pwd_agin = changPwd.changPanel.findById("new_pwd_agin")
			.getValue();
	if (changPwd.new_pwd != changPwd.new_pwd_agin) {
		Ext.Msg.show({
					title : '提示信息',
					msg : '两次密码输入不一致',
					buttons : Ext.Msg.OK
				});
		changPwd.changPanel.findById("new_pwd_agin").setValue(null);
		changPwd.changPanel.findById("new_pwd_agin").focus();
		return;
	}
	if (changPwd.user_name == null || changPwd.user_name.trim() == "") {
		Ext.Msg.show({
					title : '提示信息',
					msg : '用户名必填',
					buttons : Ext.Msg.OK
				});
		changPwd.changPanel.findById("user_name").focus();
		return;
	};
	if (changPwd.pwd == null || changPwd.pwd.trim() == "") {
		Ext.Msg.show({
					title : '提示信息',
					msg : '原密码必填',
					buttons : Ext.Msg.OK
				});
		changPwd.changPanel.findById("pwd").focus();
		return;
	};
	if (changPwd.new_pwd == null || changPwd.new_pwd.trim() == "") {
		Ext.Msg.show({
					title : '提示信息',
					msg : '新密码必填',
					buttons : Ext.Msg.OK
				});
		changPwd.changPanel.findById("new_pwd").focus();
		return;
	};
	if (changPwd.new_pwd_agin == null || changPwd.new_pwd_agin.trim() == "") {
		Ext.Msg.show({
					title : '提示信息',
					msg : '确认密码必填',
					buttons : Ext.Msg.OK
				});
		changPwd.changPanel.findById("new_pwd_agin").focus();
		return;
	};
	Ext.Ajax.request({
				url : 'ChangePwd!changPwd.action',
				success : function(result, request) {
					var failstr = Ext.util.JSON.decode(result.responseText);
					if (failstr.resultString != "") {
						Ext.Msg.show({
									title : '提示信息',
									msg : failstr.resultString,
									buttons : Ext.Msg.OK
								});
						changPwd.changPanel.findById("pwd").setValue(null);
						changPwd.changPanel.findById("new_pwd").setValue(null);
						changPwd.changPanel.findById("new_pwd_agin")
								.setValue(null);
						changPwd.changPanel.findById("pwd").focus();
					} else {
						Ext.Msg.show({
									title : '提示信息',
									msg : '处理成功',
									buttons : Ext.Msg.OK
								});
					}
				},
				failbure : function(result, request) {
					var failstr = Ext.decode(result.responseText);
					Ext.Msg.show({
								title : '提示信息',
								msg : '处理失败',
								buttons : Ext.Msg.OK
							});
				},
				params : {
					user_name : changPwd.user_name,
					pwd : changPwd.pwd,
					newpwd : changPwd.new_pwd,
					newpwdagin : changPwd.new_pwd_agin
				}
			});
}